<template>
    <bi-form ref="form">
        <bi-form-item label="名称" >
            <bi-input v-model="form.title" placeholder="请输入名称"></bi-input>
        </bi-form-item>
        <bi-form-item label="图片"  >
            <bi-switch value-number v-model="form.image" placeholder="请输入名称"></bi-switch>
        </bi-form-item>
    </bi-form>
</template>

<script>
export default{
    data(){

        let  form = {
            item_id:'',
            title:'',
            image:0
        }

        this.$assign(form,this.item);

        return {
           form
        }
    },
    props:{
        variant_id:[Number,String],
        item:{
            type:Object,
            default(){
                return {};
            }
        }
    },
    methods:{
        dialogOk(){
            if (this.$refs.form.check()){
                this.$ajax({
                    url:this.$url({app:'shop',controller:'admin.variant',action:'saveItem'}),
                    data:{
                        ...this.form,
                        variant_id:this.variant_id
                    },
                    success:(data)=>{
                        this.$toast('保存成功');
                        this.dialog.callback();
                        this.dialog.close();
                    }
                })
            }
        }
    }
}
</script>